package com.gxa.zhonglong.controller;

import com.gxa.zhonglong.common.JsonResult;
import com.gxa.zhonglong.exception.BusinessException;
import com.gxa.zhonglong.mapper.StoneMapper;
import com.gxa.zhonglong.pojo.*;
import com.gxa.zhonglong.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author NITRO
 */

@Api
@CrossOrigin
@RestController
@RequestMapping("/Stone")
public class StoneController {

    @Autowired
    private StoneService stoneService;

    @Autowired
    private StoneClarityService stoneClarityService;

    @Autowired
    private StoneColorService stoneColorService;

    @Autowired
    private StoneCutService stoneCutService;

    @Autowired
    private StoneShapeService stoneShapeService;

    @Autowired
    private StoneTypeService stoneTypeService;

    @Autowired
    private StoneFireService stoneFireService;

    /**
     * 返回石料名称(下拉框需要的数据)
     * @return
     */
    @ApiOperation(value = "返回石料名称(下拉框需要的数据)")
    @PostMapping("/getStoneNameList")
    public Map getStoneNameList() {
        List<StoneMapper> stonesNamesList = stoneService.getStonesNamesList();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(stonesNamesList);
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    //石料净度的增删改查

    /**
     * 查询石料净度

     * @return
     */
    @ApiOperation(value = "查询石料净度")
    @PostMapping("/getStoneClarityList")

    public Map getStoneClarityList(){
        List<StoneClarity> stoneClarity = stoneClarityService.getStoneClarity();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(stoneClarity);
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 添加石料净度
     * @param stoneClarity
     * @return
     */
    @ApiOperation(value = "添加石料净度")
    @PostMapping("addStoneClarity")
    public Map addStoneClarity( StoneClarity stoneClarity) throws BusinessException {
        JsonResult jsonResult=new JsonResult();
        stoneClarityService.addStoneClarity(stoneClarity);
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 删除石料净度
     * @return
     */
    @ApiOperation(value = "删除石料净度")
    @PostMapping("deleteStoneClarity")

    public Map<String,Object> deleteCharges(@RequestBody Map<String,List<Long>> ids) throws BusinessException {
        stoneClarityService.deleteStoneClarity(ids.get("ids"));
        JsonResult jsonResult=new JsonResult();
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 修改石料净度
     * @param stoneClarity
     * @return
     */
    @ApiOperation(value = "修改石料净度")
    @PostMapping("updateStoneClarity")
    public Map updateStoneCharity( StoneClarity stoneClarity) throws BusinessException {
        JsonResult jsonResult=new JsonResult();
        stoneClarityService.updateStoneClarity(stoneClarity);
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    //石料颜色的增删改查

    @ApiOperation(value = "查询石料颜色")
    @PostMapping("/getStoneColorList")

    public Map getStoneColorList(){
        List<StoneColor> stoneColor = stoneColorService.getStoneColor();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(stoneColor);
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 添加石料颜色
     * @param stoneColor
     * @return
     */
    @ApiOperation(value = "添加石料颜色")
    @PostMapping("addStoneColor")
    public Map addStoneColor( StoneColor stoneColor) throws BusinessException {
        JsonResult jsonResult=new JsonResult();
        Boolean add = stoneColorService.addStoneColor(stoneColor);
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 删除石料颜色
     * @return
     */
    @ApiOperation(value = "删除石料颜色")
    @PostMapping("deleteStoneColor")

    public Map<String,Object> deleteColor(@RequestBody Map<String,List<Long>> ids) throws BusinessException {
        stoneColorService.deleteStoneColor(ids.get("ids"));
        JsonResult jsonResult=new JsonResult();
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 修改石料颜色
     * @param stoneColor
     * @return
     */
    @ApiOperation(value = "修改石料颜色")
    @PostMapping("updateStoneColor")

    public Map updateStoneColor( StoneColor stoneColor) throws BusinessException {
        JsonResult jsonResult=new JsonResult();

        Boolean update = stoneColorService.updateStoneColor(stoneColor);
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }


    //石料切工增删改查

    /**
     * 查询石料切工

     * @return
     */
    @ApiOperation(value = "查询石料切工")
    @PostMapping("/getStoneCutList")

    public Map getStoneCutList(){
        List<StoneClarity> stoneCutList = stoneCutService.getStoneCutList();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(stoneCutList);
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 添加石料切工
     * @param stoneCut
     * @return
     */
    @ApiOperation(value = "添加石料切工")
    @PostMapping("addStoneCut")

    public Map addStoneCut( StoneCut stoneCut) throws BusinessException {
        JsonResult jsonResult=new JsonResult();

        stoneCutService.addStoneCut(stoneCut);

        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 删除石料切工

     * @return
     */
    @ApiOperation(value = "删除石料切工")
    @PostMapping("deleteStoneCut")
    public Map<String,Object> deleteCut(@RequestBody Map<String,List<Long>> ids) throws BusinessException {
        stoneCutService.deleteStoneCut(ids.get("ids"));
        JsonResult jsonResult=new JsonResult();
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 修改石料切工
     * @param stoneCut
     * @return
     */
    @ApiOperation(value = "修改石料切工")
    @PostMapping("updateStoneCut")

    public Map updateStoneCut( StoneCut stoneCut) throws BusinessException {
        JsonResult jsonResult=new JsonResult();

        stoneCutService.updateStoneCut(stoneCut);

        jsonResult.setCode("1");

        return jsonResult.getDataMap();
    }


    //石料形状的增删改查

    /**
     * 查询石料形状

     * @return
     */
    @ApiOperation(value = "查询石料形状")
    @PostMapping("/getStoneShapeList")

    public Map getStoneShapeList(){
        List<StoneShape> stoneShapeList = stoneShapeService.getStoneShapeList();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(stoneShapeList);
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 添加石料形状
     * @param stoneShape
     * @return
     */
    @ApiOperation(value = "添加石料形状")
    @PostMapping("addStoneShape")

    public Map addStoneShape( StoneShape stoneShape) throws BusinessException {
        JsonResult jsonResult=new JsonResult();
        stoneShapeService.addStoneShape(stoneShape);

        jsonResult.setCode("1");

        return jsonResult.getDataMap();
    }

    /**
     * 删除石料形状
     * @return
     */
    @ApiOperation(value = "删除石料形状")
    @PostMapping("deleteStoneShape")

    public Map<String,Object> deleteShape(@RequestBody Map<String,List<Long>> ids) throws BusinessException {
        stoneShapeService.deleteStoneShape(ids.get("ids"));
        JsonResult jsonResult=new JsonResult();
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 修改石料形状
     * @param stoneShape
     * @return
     */
    @ApiOperation(value = "修改石料形状")
    @PostMapping("updateStoneShape")

    public Map updateStoneShape( StoneShape stoneShape) throws BusinessException {
        JsonResult jsonResult=new JsonResult();
        stoneShapeService.updateStoneShape(stoneShape);

        jsonResult.setCode("1");

        return jsonResult.getDataMap();
    }




    //石料种类的增删改查

    /**
     * 查询石料种类
     * @return
     */
    @ApiOperation(value = "查询石料种类")
    @PostMapping("/getStoneTypeList")

    public Map getStoneTypeList(){
        List<StoneType> stoneTypeList = stoneTypeService.getStoneTypeList();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(stoneTypeList);
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 添加石料种类
     * @param stoneType
     * @return
     */
    @ApiOperation(value = "添加石料种类")
    @PostMapping("addStoneType")

    public Map addStoneType( StoneType stoneType) throws BusinessException {
        JsonResult jsonResult=new JsonResult();

        Boolean aBoolean = stoneTypeService.addStoneType(stoneType);

        jsonResult.setCode("1");

        return jsonResult.getDataMap();
    }

    /**
     * 删除石料种类

     * @return
     */
    @ApiOperation(value = "删除石料种类")
    @PostMapping("deleteStoneType")
    public Map<String,Object> deleteType(@RequestBody Map<String,List<Long>> ids) throws BusinessException {
        stoneTypeService.deleteStoneType(ids.get("ids"));
        JsonResult jsonResult=new JsonResult();
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 修改石料种类
     * @param stoneType
     * @return
     */
    @ApiOperation(value = "修改石料种类")
    @PostMapping("updateStoneType")
    public Map updateStoneShape( StoneType stoneType) throws BusinessException {
        JsonResult jsonResult=new JsonResult();

        stoneTypeService.updateStoneType(stoneType);

        jsonResult.setCode("1");

        return jsonResult.getDataMap();
    }


    //石料火彩的增删改查

    /**
     * 查询石料火彩

     * @return
     */
    @ApiOperation(value = "查询石料火彩")
    @PostMapping("/getStoneFireList")

    public Map getStoneFireList(){
        List<StoneFire> stoneFireList = stoneFireService.getStoneFireList();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(stoneFireList);
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 添加石料火彩
     * @param stoneFire
     * @return
     */
    @ApiOperation(value = "添加石料火彩")
    @PostMapping("addStoneFire")
    public Map addStoneFire( StoneFire stoneFire) throws BusinessException {
        JsonResult jsonResult=new JsonResult();
        stoneFireService.addStoneFire(stoneFire);

        jsonResult.setCode("1");

        return jsonResult.getDataMap();
    }

    /**
     *删除石料火彩
     * @return
     */
    @ApiOperation(value = "删除石料火彩")
    @PostMapping("deleteStoneFire")
    public Map<String,Object> deleteFire(@RequestBody Map<String,List<Long>> ids) throws BusinessException {
        stoneFireService.deleteStoneFire(ids.get("ids"));
        JsonResult jsonResult=new JsonResult();
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    /**
     * 修改石料火彩
     * @param stoneFire
     * @return
     */
    @ApiOperation(value = "修改石料火彩")
    @PostMapping("updateStoneFire")

    public Map updateStoneFire( StoneFire stoneFire) throws BusinessException {
        JsonResult jsonResult=new JsonResult();

        stoneFireService.updateStoneFire(stoneFire);

        jsonResult.setCode("1");

        return jsonResult.getDataMap();
    }
}
